import http from '../utils/request'

// ================ 团队 =======================
export interface Team {
    id: string;
    teamName: string;
    parentId: string;
    maxUserNum: number;
    balanceUserNum: number;
    status: number;
    creator: string;
    creatorId: number;
    createTime: number;
}

interface TeamPage {
    list: Team[];
}

export interface SearchTeam {
    page: number;
    pageSize: number;
    teamName: string;
}

export interface TeamForm {
    id: string;
    teamName: string;
    parentId: string;
    maxUserNum: number;
    status: number;
    appIds: string[];
}

// 获取团队分页信息
export const getPage = (data: SearchTeam): Promise<TeamPage> => {
  return http.get('/team/page', { params: data })
}

// 添加团队
export const addTeam = (data: TeamForm) => {
  return http.post('/team/add', data)
}

// 添加团队
export const updateTeam = (data: TeamForm) => {
  return http.post('/team/update', data)
}

// 删除团队
export const getDetail = (teamId: string): Promise<TeamForm> => {
  return http.get('/team/detail', { params: { teamId } })
}

// 删除团队
export const deleteTeam = (teamId: string) => {
  return http.delete('/team/delete', { params: { teamId } })
}
